home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 7_6.lha / 7_6 / 7_6_getp.c < prev    next >
Text File  |  1993-08-08  |  554b  |  39 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / Get the previous entry from a list,
  6. / removing it afterwards
  7. nt dlist::getprev(ent &a)
  8.  
  9.    if (!last)
  10. return 0;
  11.  
  12.    // choose the link to remove
  13.    dlink *f;
  14.    if (curr)
  15. if (curr == last->prev)
  16.     {
  17.     curr = 0;
  18.     return 0;
  19.     }
  20.  
  21. else
  22.     f = curr->prev;
  23.  
  24.    else
  25. f = curr = last;
  26.  
  27.    a = f->e;
  28.  
  29.    // remove f from the list
  30.    if (f == last)
  31. last = 0;
  32.  
  33.    else
  34. f->remove();
  35.  
  36.    delete f;
  37.    return 1;
  38.  
  39.